package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: Sabrina
 * @Date:2025/06/13/15:52
 * @Description:
 */
@Mapper
public interface ShoppingCartMapper {
    /**
     * 添加一条数据到购物车表
     * @param shoppingCart
     */
    @Insert("insert into shopping_cart (name,user_id,dish_id,setmeal_id,dish_flavor,number,amount,image,create_time)" +
            " values (#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{image},#{createTime})")
    void addCart(ShoppingCart shoppingCart);

    List<ShoppingCart> getCart(ShoppingCart shoppingCart);

    void update(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void clean(Long userId);

    /**
     * 删除购物车中的一条数据
     * @param shoppingCart
     */
    void delete(ShoppingCart shoppingCart);

    /**
     * 把取消支付的商品重新添加回购物车
     * @param shoppingCarts
     */
    void addCarts(List<ShoppingCart> shoppingCarts);
}
